package com.ny.demo526;

import com.ny.demo526.Emp;
import com.ny.demo526.TestSet;

import java.util.*;

public class ViewMain {
    public static void main(String[] args) {
        boolean flag = true;
        TestSet testList = new TestSet();
        Set<Emp> empSet = new HashSet<>();
        while (flag){
            menu();
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            switch (n){
                case 0:
                    System.out.println("退出系统");
                    flag = false;
                    break;
                case 1:
                    System.out.println("添加员工界面");
                    System.out.println("请输入员工信息");
                    System.out.println("请输入员工编码");
                    String number = scanner.next();
                    System.out.println("请输入员工姓名");
                    String name = scanner.next();
                    System.out.println("请输入员工年龄");
                    int age = scanner.nextInt();
                    Emp emp = new Emp(number,name,age);
                    testList.addEmp(new ArrayList<>(empSet), emp);
                    empSet.add(emp);
                    System.out.println(empSet);
                    break;
                case 2:
                    System.out.println("来到查询所有员工信息的界面");
                    testList.findAllEmp(new ArrayList<>(empSet));
                    break;
                case 3:
                    System.out.println("来到查询员工信息的界面");
                    System.out.println("请输入员工的姓名");
                    String findName = scanner.next();
                    testList.findEmpName(new ArrayList<>(empSet), findName);
                    break;
                case 4:
                    System.out.println("来到删除员工信息的界面");
                    System.out.println("请输入员工的工号");
                    String deleteEmpNumber = scanner.next();
                    testList.deleteEmpNumber(new ArrayList<>(empSet), deleteEmpNumber);
                    empSet.removeIf(e -> e.getNumber().equals(deleteEmpNumber));
                    break;
                case 5:
                    System.out.println("来到查询员工信息的界面");
                    System.out.println("请输入员工的编号");
                    String findNumber = scanner.next();
                    testList.findEmpNumber(new ArrayList<>(empSet), findNumber);
                    break;
                case 6:
                    System.out.println("来到根据员工编号修改员工年龄");
                    System.out.println("请输入需要修改的员工的编号");
                    String updateEmpNumber = scanner.next();
                    Emp emp1 = testList.findEmpNumber(new ArrayList<>(empSet), updateEmpNumber);
                    System.out.println("请输入你需要修改的年龄为：");
                    int updateAge = scanner.nextInt();
                    emp1.setAge(updateAge);
                    testList.updateEmpAge(new ArrayList<>(empSet), emp1);  // 修改10
                    System.out.println(empSet);
                    break;
            }
        }
    }
    public static void menu(){
        System.out.println("欢迎来到员工信息管理系统");
        System.out.println("0.退出系统");
        System.out.println("1.添加员工");
        System.out.println("2.查询所有员工");
        System.out.println("3.根据员工姓名查询");
        System.out.println("4.删除员工");
        System.out.println("5.根据员工编号查询");
        System.out.println("6.根据员工编号修改年龄");
        System.out.println("请选择你需要进行的操作");
    }
}